package com.shengdou.as.slopsapptest.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 检查电话号码工具类
 * @author zhaolifeng
 *
 */
public class CheckPhoneUtil {
	/**
	 * 判断电话号码是否可用
	 * @param phoneNumber
	 * @return
	 */
	public static boolean isPhoneNumberValid(String phoneNumber) {
		boolean isValid = false;
		String expression = "((^(13|14|15|17|18)[0-9]{9}$)|(^0[1,2]{1}\\d{1}-?\\d{8}$)|(^0[3-9] {1}\\d{2}-?\\d{7,8}$)|(^0[1,2]{1}\\d{1}-?\\d{8}-(\\d{1,4})$)|(^0[3-9]{1}\\d{2}-? \\d{7,8}-(\\d{1,4})$))";
		CharSequence inputStr=phoneNumber;
		Pattern pattern= Pattern.compile(expression);
		Matcher matcher=pattern.matcher(inputStr);
		if(matcher.matches()){
			return true;
		}
		return isValid;
	}
}
